<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>导入库配置</title>
	<style type="text/css">
		.fileds {
			bgcolor:#0000dd; 
			width:100px;
			margin-right:10px
		}
	</style>
	<script type="text/javascript">
		function checkDB() {
			var db = $("#db").val();
			var host = $("#host").val();
			var port = $("#port").val();
			var dbName = $("#dbName").val();
			var userName = $("#userName").val();
			var password = $("#password").val();
			var importSql = $("#importSql").val();
			
			var taskId = $("#taskId").val();
			var taskMsg = $("#taskMsg");
			
			var dbMsg = $("#dbMsg");
			var hostMsg = $("#hostMsg");
			var portMsg = $("#portMsg");
			var dbNameMsg = $("#dbNameMsg");
			var userNameMsg = $("#userNameMsg");
			var passwordMsg = $("#passwordMsg");
			var importSqlMsg = $("#importSqlMsg");
			
			if($.trim(taskId) == "") {
				taskMsg.html("没有指定任何任务");
			} else {
				taskMsg.html("");
			}
			
			if($.trim(db) == "") {
				dbMsg.html("数据库管理系统不能为空");
			} else {
				dbMsg.html("");
			}
			
			if($.trim(host) == "") {
				hostMsg.html("主机名不能为空");
			} else {
				hostMsg.html("");
			}
			
			if($.trim(port) == "") {
				portMsg.html("端口号不能为空");
			} else {
				portMsg.html("");
			}
			
			if($.trim(dbName) == "") {
				dbNameMsg.html("数据库名称不能为空");
			} else {
				dbNameMsg.html("");
			}
			
			if($.trim(userName) == "") {
				userNameMsg.html("数据库用户名不能为空");
			} else {
				userNameMsg.html("");
			}
			
			if($.trim(importSql) == "") {
				importSqlMsg.html("导入SQL不能为空");
			} else {
				importSqlMsg.html("");
			}
		}
		
		function changeDb() {
			var db = $("#db").val();
			var port = $("#port");
			if(db == "MYSQL") {
				port.val(3306);
			} else if(db == "SQLSERVER") {
				port.val(1433);
			} else if(db == "SQLSERVER2005") {
				port.val(1433);
			} else if(db == "ORACLE") {
				port.val(1521);
			}
		}
	</script>
</head>
  <body>
       <div class="content_bg">
 	 	<div class="rhead">
 	 		<div class="rpos">当前位置:  数据采集 - 导入库配置</div>
 	 	</div>
 	 	
 	 	<s:form action="createDbCollectionTask" theme="simple" onsubmit="return checkDB()">
 	 	<s:hidden name="collectionTask.id" id="taskId"></s:hidden>
 	 	<div class="rhead">
 	 		<div class="textRow"><div class="textLabel">任务名称：</div>
 	 		<div class="textContent">
 	 		&nbsp;<s:property value="collectionTask.taskName" escape="false"/> <span id="taskMsg" style="color:red"></span>
 	 		</div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">数据库管理系统(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:select name="dbConfig.db" cssClass="textInfo" list="#{'MYSQL':'MYSQL','SQLSERVER':'SQLSERVER','SQLSERVER2005':'SQLSERVER2005','ORACLE':'ORACLE'}"  id="db" onchange="changeDb()" headerKey="" headerValue="请选择"/><span id="dbMsg" style="color:red"></span></div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">数据库主机(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:textfield name="dbConfig.host" cssClass="textInfo" size="80" maxlength="100" id="host"/><span id="hostMsg" style="color:red"></span></div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">端口号(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:textfield name="dbConfig.port" cssClass="textInfo" size="20" maxlength="100" id="port"/><span id="portMsg" style="color:red"></span></div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">数据库名称(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:textfield name="dbConfig.dbName" cssClass="textInfo" size="50" maxlength="100" id="dbName" /><span id="dbNameMsg" style="color:red"></span></div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">用户名(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:textfield name="dbConfig.userName" cssClass="textInfo" size="50" maxlength="100" id="userName" /><span id="userNameMsg" style="color:red"></span></div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">用户密码(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:password name="dbConfig.password" cssClass="textInfo" size="50" maxlength="100" id="password" /><span id="passwordMsg" style="color:red"></span></div>
 	 		</div>
 	 		
 	 		<div class="textRow"><div class="textLabel">采集字段：</div>
 	 		<div class="textContent">&nbsp;&nbsp;
 	 				<s:iterator value="collectionStrategies" var="collectionStrategy" status="stat">
 	 					<s:if test="!#stat.first">
 	 						<span class="fileds"><s:property value="#collectionStrategy.filedName" escape="false"/></span>
 	 					</s:if>
 	 				</s:iterator>
 	 		</div>
 	 		</div>
 	 		<div class="textRow"><div class="textLabel">导入SQL(<span style="color:red">*</span>)：</div>
 	 		<div class="textContent"><s:textarea name="dbConfig.importSQL" cols="100" rows="8" id="importSql"></s:textarea><span id="importSqlMsg" style="color:red"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(注：使用采集字段组织导入SQL,形式如下：insert into table_name(字段一, 字段二, 字段三) values(:字段一, :字段二, :字段三))</span></div>
 	 		</div>
 	 	</div>
 	 	<div class="rhead">
 	 		<span style="margin-left:140px"><s:submit value="提交"></s:submit></span>
 	 	</div>
 	 		</s:form>
 	   </div>
  </body>
</html>



